package com.web.common.document.api;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.ResponseBody;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.web.common.api.config.ServiceInstanceName;
import com.web.common.document.entity.DocumentChapterEntity;
import com.web.common.document.entity.DocumentContent;
import com.web.common.document.entity.DocumentContentEntity;
import com.web.common.document.entity.DocumentInfoEntity;
import com.web.common.document.entity.ShareDocInfo;
import com.web.common.result.R;
import com.web.common.security.FeignInnerEntity;

@FeignClient(name = ServiceInstanceName.SERVICE_DOCUMENT_NAME, contextId = "documentInfoApi", path = "/doc/info")
public interface DocumentInfoApi {

	/**
	 * 获取属于自己的文档信息列表
	 * @param condition 查询条件
	 * @return List<DocumentInfoEntity> 文档信息列表
	 *
	 * @author zhouhui
	 * @since 2023.12.08 
	 */
	@PostMapping(path = "/list")
	@ResponseBody
	R<IPage<DocumentInfoEntity>> getDocInfoList(@RequestBody DocumentInfoEntity condition);
	
	/**
	 * 获取文档信息详情（主要是指定人员的信息）
	 * @param condition 查询条件
	 * @return 
	 *
	 * @author zhouhui
	 * @since 2024.02.27 
	 */
	@PostMapping(path = "/detail")
	@ResponseBody
	R<DocumentInfoEntity> getDocInfoDetail(@RequestBody DocumentInfoEntity condition);
	
	/**
	 * 保存文档信息
	 * @param info 文档信息
	 * @return R<Object> 处理结果
	 *
	 * @author zhouhui
	 * @since 2023.12.08 
	 */
	@PostMapping(path = "/save")
	@ResponseBody
	R<Object> saveDocInfo(@Validated @RequestBody DocumentInfoEntity info);
	
	/**
	 * 更新文档信息
	 * @param info 文档信息
	 * @return R<Object> 处理结果
	 *
	 * @author zhouhui
	 * @since 2023.12.11 
	 */
	@PostMapping(path = "/update")
	@ResponseBody
	R<Object> updateDocInfo(@Validated @RequestBody DocumentInfoEntity info);
	
	/**
	 * 删除文档信息
	 * @param info 需要删除的文档Id
	 * @return R<Object> 处理结果
	 *
	 * @author zhouhui
	 * @since 2023.12.12 
	 */
	@PostMapping(path = "/delete")
	@ResponseBody
	R<Object> deleteDocInfo(@RequestBody DocumentInfoEntity info);
	
	/**
	 * 保存文档信息的文档章节信息
	 * @param chapter 章节信息
	 * @return R<Object> 处理结果
	 *
	 * @author zhouhui
	 * @since 2023.12.12 
	 */
	@PostMapping(path = "/chapter/save")
	@ResponseBody
	R<Object> saveChapter(@Validated @RequestBody DocumentChapterEntity chapter);
	
	/**
	 * 删除章节信息
	 * @param chapter 需要删除的章节
	 * @return R<Object> 处理结果
	 *
	 * @author zhouhui
	 * @since 2023.12.17
	 */
	@PostMapping(path = "/chapter/delete")
	@ResponseBody
	R<Object> deleteChapter(@RequestBody DocumentChapterEntity chapter);
	
	
	/**
	 * 更新章节信息
	 * @param chapter 章节信息
	 * @return R<Object> 处理结果
	 *
	 * @author zhouhui
	 * @since 2023.12.17
	 */
	@PostMapping(path = "/chapter/update")
	@ResponseBody
	R<Object> updateChapter(@RequestBody DocumentChapterEntity chapter);
	
	/**
	 * 保存/更新文档内容
	 * @param content 文档内容信息
	 * @return  R<Object>处理结果
	 *
	 * @author zhouhui
	 * @since 2023.12.14
	 */
	@PostMapping(path = "/content/save")
	@ResponseBody
	R<Object> saveContent(@Validated @RequestBody DocumentContentEntity content);
	
	/**
	 * 自动取消分享信息
	 * @param inner 
	 * @return R<Object> 处理结果
	 *
	 * @author zhouhui
	 * @since 2024.01.14
	 */
	@GetMapping(path = "/autoCancel/share")
	@ResponseBody
	R<Object> autoCancelShare(@RequestHeader(name = FeignInnerEntity.HTTP_HEADER_INNER, required = false) String inner);
	
	/**
	 * 根据文档Id获取章节列表
	 * @param chapter 文档Id
	 * @return R<ShareDocInfo> 章节列表
	 *
	 * @author zhouhui
	 * @since 2024.01.14
	 */
	@PostMapping(path = "/chapter/list")
	@ResponseBody
	R<ShareDocInfo> getChapterList(@RequestBody DocumentChapterEntity chapter);
	
	/**
	 * 获取文档内容
	 * @param content 查询条件
	 * @return R<DocumentContent> 文档内容
	 *
	 * @author zhouhui
	 * @since 2024.01.14
	 */
	@PostMapping(path = "/docment/conent")
	@ResponseBody
	R<DocumentContent> getDocumentConent(@RequestBody DocumentContentEntity content);
}
